package infopanel;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.ws.Endpoint;
import queues.NotificationsService;

/**
 *
 * @author Renato Rosa <2101076@my.ipleiria.pt>
 */
@WebService(name = "InfoPanelNotifService", serviceName = "InfoPanelNotifService", portName = "InfoPanelNotifService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public final class InfoPanelNotifService extends NotificationsService<SoundProducer> {
    private String port = "3333";

    @Override
    protected Endpoint publish(String ipAddress) {
        String address = "http://" + ipAddress + ":" + port + "/InfoPanelNotifService";
        Endpoint endp = Endpoint.create(this);
        endp.setExecutor(singleThread);
        endp.publish(address);
        System.out.println("Web service was published successfully.\n" + "WSDL URL: " + address + "?WSDL");
        return endp;
    }
    
    @WebMethod
    public String setSoundOptions(@WebParam @XmlElement(required = true) boolean useAlert, @WebParam @XmlElement(required = true) boolean useVoice) {
        for (SoundProducer p : observers) {
            p.setSoundOptions(useAlert, useVoice);
        }
        return "OK";
    }
 
}
